package com.hele.sts.webdoc;

import java.sql.ResultSet;
import java.sql.SQLException;

import com.hele.sts.pub.SqlQuery;
import com.hele.sts.pub.SqlUpdate;

public class QyzhBean
{
  SqlQuery sqlquery;
  SqlUpdate sqlupdate;
  
  public QyzhBean()
  {
    this.sqlupdate = null;
    this.sqlquery = null;
  }
  
  public ResultSet getQynbxhResult(String tZch, String DataS)
    throws SQLException
  {
    ResultSet rs = null;
    this.sqlquery = new SqlQuery(DataS);
    String sqlstr = "";
    sqlstr = "select * from hz_qyhznr where 1=1 ";
    if (tZch!=null&&!tZch.equals("")) {
      sqlstr = sqlstr + " and zch = '" + tZch.trim() + "'";
    } else {
      sqlstr = sqlstr + " and 1=2";
    }
    rs = this.sqlquery.getResultSet(sqlstr);
    return rs;
  }
  
  public ResultSet getQyzhQueryList(String tQymc, String tZch, String tFddbr, String tJycs, String tZs, String tGxdw, String tDjjg, String tJyfw, String tQylxq, String tQylxz, String tHydmq, String tHydmz, String tClrqq, String tClrqz, String tHzrqq, String tHzrqz, String tZczbq, String tZczbz, String tZczbmyq, String tZczbmyz, String tDabhq, String tDabhz, String queryLimitedJoin)
  {
    ResultSet rs = null;
    this.sqlquery = new SqlQuery("jjhkDataSource2");
    String sqlstr = "";
    sqlstr = "select a.nbxh,a.zch,a.qymc,a.fddbr,a.hzrq,a.qylx,a.hy,a.zczb,a.zs,a.clrq,t2.content,t3.content from hz_qyhznr a,bm_qylx t2,bm_hy t3 where a.qylx =t2.code(+) and a.hy = t3.code(+)" + queryLimitedJoin;
    if (!tQymc.equals("")) {
      sqlstr = sqlstr + " and qymc like '%" + tQymc.trim() + "%'";
    }
    if (tZch!=null&&!tZch.equals("")) {
      sqlstr = sqlstr + " and zch like '%" + tZch.trim() + "%'";
    }
    if (!tFddbr.equals("")) {
      sqlstr = sqlstr + " and fddbr like '%" + tFddbr.trim() + "%'";
    }
    if (!tJycs.equals("")) {
      sqlstr = sqlstr + " and jycs like '%" + tJycs.trim() + "%'";
    }
    if (!tZs.equals("")) {
      sqlstr = sqlstr + " and zs like '%" + tZs.trim() + "%'";
    }
    if (!tGxdw.equals("")) {
      sqlstr = sqlstr + " and gxdw = '" + tGxdw.trim() + "'";
    }
    if (!tDjjg.equals("")) {
      sqlstr = sqlstr + " and djjg = '" + tDjjg.trim() + "'";
    }
    if (!tJyfw.equals("")) {
      sqlstr = sqlstr + " and jyfw like '%" + tJyfw.trim() + "%'";
    }
    if (!tQylxq.equals("")) {
      sqlstr = sqlstr + " and qylx >= '" + tQylxq.trim() + "'";
    }
    if (!tQylxz.equals("")) {
      sqlstr = sqlstr + " and qylx <= '" + tQylxz.trim() + "'";
    }
    if (!tHydmq.equals("")) {
      sqlstr = sqlstr + " and hy >= '" + tHydmq.trim() + "'";
    }
    if (!tHydmz.equals("")) {
      sqlstr = sqlstr + " and hy <= '" + tHydmz.trim() + "'";
    }
    if (!tClrqq.equals("")) {
      sqlstr = sqlstr + " and clrq >= to_date('" + tClrqq.trim() + "','YYYY-MM-DD')";
    }
    if (!tClrqz.equals("")) {
      sqlstr = sqlstr + " and clrq <= to_date('" + tClrqz.trim() + "','YYYY-MM-DD')";
    }
    if (!tHzrqq.equals("")) {
      sqlstr = sqlstr + " and hzrq >= to_date('" + tHzrqq.trim() + "','YYYY-MM-DD')";
    }
    if (!tHzrqz.equals("")) {
      sqlstr = sqlstr + " and hzrq <= to_date('" + tHzrqz.trim() + "','YYYY-MM-DD')";
    }
    if (!tZczbq.equals("")) {
      sqlstr = sqlstr + " and zczb >= " + tZczbq.trim();
    }
    if (!tZczbz.equals("")) {
      sqlstr = sqlstr + " and zczb <= " + tZczbz.trim();
    }
    if (!tZczbmyq.equals("")) {
      sqlstr = sqlstr + " and zczbmy >= " + tZczbmyq.trim();
    }
    if (!tZczbmyz.equals("")) {
      sqlstr = sqlstr + " and zczbmy <= " + tZczbmyz.trim();
    }
    if (!tDabhq.equals("")) {
      sqlstr = sqlstr + " and dah >= '" + tDabhq.trim() + "'";
    }
    if (!tDabhz.equals("")) {
      sqlstr = sqlstr + " and dah <= '" + tDabhz.trim() + "'";
    }
    try
    {
      rs = this.sqlquery.getResultSet(sqlstr);
    }
    catch (SQLException e)
    {
      e.printStackTrace();
    }
    return rs;
  }
  
  public ResultSet getQyzhResult(String tNbxh)
    throws SQLException
  {
    ResultSet rs = null;
    this.sqlquery = new SqlQuery();
    String sqlstr = "";
    sqlstr = "select * from hz_qyhznr where 1=1 ";
    if (!tNbxh.equals("")) {
      sqlstr = sqlstr + " and nbxh = '" + tNbxh.trim() + "'";
    } else {
      sqlstr = sqlstr + " and 1=2";
    }
    rs = this.sqlquery.getResultSet(sqlstr);
    return rs;
  }
  
  public ResultSet getQyzhResultWhole(String tNbxh, String tBfxh, String DataS)
  {
    ResultSet rs = null;
    this.sqlquery = new SqlQuery();
    String sqlstr = "";
    sqlstr = "select * from bf_qyhznr where 1=1 and zt in ('D','X','Q') ";
    if ((!tNbxh.equals("")) && (!tBfxh.equals(""))) {
      sqlstr = sqlstr + " and nbxh = '" + tNbxh.trim() + "'" + " and bfxh = '" + tBfxh.trim() + "'";
    } else {
      sqlstr = sqlstr + " and 1=2";
    }
    try
    {
      rs = this.sqlquery.getResultSet(sqlstr);
    }
    catch (SQLException e)
    {
      e.printStackTrace();
    }
    return rs;
  }
  
  public ResultSet getQyzhResultWhole(String tNbxh, String DataS)
  {
    ResultSet rs = null;
    this.sqlquery = new SqlQuery();
    String sqlstr = "";
    sqlstr = "select * from hz_qyhznr where 1=1 ";
    if (!tNbxh.equals("")) {
      sqlstr = sqlstr + " and nbxh = '" + tNbxh.trim() + "'";
    } else {
      sqlstr = sqlstr + " and 1=2";
    }
    try
    {
      rs = this.sqlquery.getResultSet(sqlstr);
    }
    catch (SQLException e)
    {
      e.printStackTrace();
    }
    return rs;
  }
  
  public void queryclose()
  {
    try
    {
      this.sqlquery.close();
    }
    catch (SQLException e)
    {
      e.printStackTrace();
    }
  }
  
  public void updateclose()
  {
    this.sqlupdate.close();
  }
}
